package tpi.gui.pages.caso

import dominio.investigacion.Caso
import org.apache.wicket.markup.html.WebPage
import org.apache.wicket.markup.html.basic.Label
import org.apache.wicket.markup.html.form.Form
import org.apache.wicket.model.CompoundPropertyModel
import org.uqbar.wicket.xtend.WicketExtensionFactoryMethods
import org.uqbar.wicket.xtend.XButton
import tpi.gui.model.Investigacion

class InicioCasoPage extends WebPage {
	
	extension WicketExtensionFactoryMethods = new WicketExtensionFactoryMethods
	private final Caso caso
	private final tpi.gui.pages.InicioPage mainPage
	
	new(Caso caso, tpi.gui.pages.InicioPage mainPage) {
		this.caso = caso
		this.mainPage = mainPage
	
		addChild(new Label("nombre",caso.nombre))
		val Form<Caso> form = new Form<Caso>("casoForm", new CompoundPropertyModel(this.caso))
		form.addChild(new Label("reporte"))
		form.addChild(new XButton("resolver").onClick = [| resolver()] )
		form.addChild(new XButton("volver").onClick = [| volver()])
		addChild(form)
	}
	
	def resolver() {
		caso.vincular
		responsePage = new ResolverCasoPage(new Investigacion(caso))
	}
	
	def volver() {
		responsePage = mainPage
	}
}